<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<%@page import="db.Album"%>

<%@page import="java.util.Random"%>
<%@page import="javax.crypto.SecretKey"%>
<%@page import="utils.DesEncrypter"%>
<%@page import="javax.crypto.KeyGenerator"%><html xmlns="http://www.w3.org/1999/xhtml">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="my" tagdir="/WEB-INF/tags" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@page import=" java.text.DateFormat"%>
<%@page import="db.Picture"%>
<%@page import="presentation.Get16ImagesBean"%>
<head>
<link rel="stylesheet" type="text/css" href="css/styleGallery.css" />
<title>Регистрация</title>  
</head>

<body id="bd">
	<div id="container">
		<my:header/>
		<%
		String action = (String)request.getAttribute("action");
		if (action == null) action = "";
		if (!action.equals("done") && session.getAttribute("user")==null){ %>
		<my:menulogout/>
		<div id="midcontainer"> 
		<table align="center"><tr><td align="center">
		<form action="register" method="post">
		<h4 style="color:#fff;text-decoration: none;font-size: medium">Потребителско име:</h4>
		<input class="box" type="text" name="username"/>
		<h4 style="color:#fff;text-decoration: none;font-size: medium">Парола:</h4>
		<input class="box" type="password" name="pass1"/>
		<h4 style="color:#fff;text-decoration: none;font-size: medium">Повтори парола:</h4>
		<input class="box" type="password" name="pass2" /><br /><br />
		<%
			String code = "";
			Random r = new Random();
			int in = r.nextInt(100000);
			code = String.valueOf(in);
			SecretKey key = KeyGenerator.getInstance("DES").generateKey();
			DesEncrypter encrypter = new DesEncrypter(key);
			code = encrypter.encrypt(code);
			session.setAttribute("key", key);
		%>
		<h4 style="color:#fff;text-decoration: none;font-size: medium">Въведи числата от картината:</h4>
		<img src="image?code=<%=code %>" /> <br />
		<input type="hidden" name="gencode" value="<%=code %>" />
		<input class="box" type="text" name="code"/><br />
		<input class="button" type="submit" value="Регистрирай ме" />
		
		</form>
		</td></tr></table>
		</div>
		<%}else{ %>
			<my:menulogout/>
		<div id="midcontainer"> 
		<h1 align="center"> Браво! </h1>
		<p align="center"> Регистрацията мина успешно!!! Моля влезте с Вашето потребителско име и парола.</p>
		</div>
<%} %>
		
		  		

<my:footer/>
</body>
</html>